package com.wang.hellohibernate.models;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@SuppressWarnings("restriction")
@Entity
@Table(name = "permissions")
@XmlRootElement(name="permission")
public class Permission implements Serializable
{
	private static final long serialVersionUID = -1088255167079041151L;
	public static final String PERMIT_READ = "READ";
	public static final String PERMIT_WRITE = "WRITE";
	public static final String PERMIT_DELETE = "DELETE";
	public static final String PERMIT_ADMIN = "ADMIN";
	
	@Id
	@GeneratedValue
	@Column(name = "id", unique=true)
	private Integer id;

	@Column(name = "permit")
	private String permit;

	@Column(name = "resourceName")
	private String resourceName;
	
	@XmlAttribute
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	@XmlElement(nillable=true)
	public String getPermit() {
		return permit;
	}
	public void setPermit(String permit) {
		this.permit = permit;
	}

	@XmlElement(nillable=true)
	public String getResourceName() {
		return resourceName;
	}
	public void setResourceName(String resource) {
		this.resourceName = resource;
	}
	
	public String toString()
	{
		return "ID: " + id + " RESOURCE_NAME: " + resourceName + " PERMIT: " + permit;
	}
}
